﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;

namespace SchEdu.Framework.DataModel
{
    public class OrderOperationSortedList : Dictionary<SchEduDataSet.OrderRow, OperationSortedList>
    {
        public int GetCmax()
        {
            int Cmax = Int32.MinValue;
            // Calculate longest path
            foreach (KeyValuePair<SchEduDataSet.OrderRow, OperationSortedList> a in this)
            {
                Cmax = Math.Max(a.Value.GetProcessingTime(), Cmax);
            }
            return Cmax;
        }

        public OperationList GetNextOperations()
        {
            OperationList op = new OperationList();
            foreach (KeyValuePair<SchEduDataSet.OrderRow, OperationSortedList> item in this)
            {
                if (item.Value.Count == 0)
                {
                    continue;
                }
                op.Add(item.Value.Values[0]);
            }
            return op;
        }

        public void RemoveByOperation(SchEduDataSet.OperationRow operation)
        {
            foreach (KeyValuePair<SchEduDataSet.OrderRow, OperationSortedList> a in this)
            {
                int index = a.Value.IndexOfValue(operation);
                if (index >= 0)
                {
                    a.Value.RemoveAt(index);
                }
            }
        }


    }
}
